package com.example.controller;


import com.example.dto.ResultDTO;
import com.example.dto.UserDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/user")
@ResponseBody
@Tag(name = "用户管理")
public interface UserController {

    @Operation(summary = "启动测试接口")
    @GetMapping("/index")
    String index();

    /**
     * @CrossOrigin 支持跨域请求
     * @return
     */
    @Operation(summary = "查询接口")
    @GetMapping("/query")
    @CrossOrigin
    ResultDTO<List<UserDTO>> query();

    @Operation(summary = "新增接口")
    @PostMapping("/add")
    ResultDTO<String> add(@RequestBody UserDTO userDTO);

    @Operation(summary = "更新接口")
    @Parameters({
            @Parameter(name = "id", description = "id", in = ParameterIn.PATH)
    })
    @PutMapping("/{id}")
    ResultDTO<String> update(@RequestBody UserDTO userDTO, @PathVariable("id") String id);

    @Operation(summary = "删除接口")
    @Parameters({
            @Parameter(name = "id", description = "id", in = ParameterIn.PATH)
    })
    @DeleteMapping("/{id}")
    ResultDTO<String> delete(@PathVariable("id") String id);

}
